package com.tjhzzx.danfossNiagaraCore.model.common;

import com.tjhzzx.danfossNiagaraCore.enums.BSubSystemType;

import javax.baja.sys.Flags;
import javax.baja.sys.Property;
import javax.baja.sys.Sys;
import javax.baja.sys.Type;
import javax.baja.util.BFolder;

public class BCommonSubSystem extends BBaseComponent {

    public static final Property lockToIndex = newProperty(Flags.HIDDEN, true, null);

    public boolean getLockToIndex() {
        return getBoolean(lockToIndex);
    }

    public void setLockToIndex(boolean v) {
        setBoolean(lockToIndex, v, null);
    }

    public static final Property redirectToBase = newProperty(Flags.HIDDEN, false, null);

    public boolean getRedirectToBase() {
        return getBoolean(redirectToBase);
    }

    public void setRedirectToBase(boolean v) {
        setBoolean(redirectToBase, v, null);
    }

    public static final Property baseUrl = newProperty(Flags.HIDDEN, "http://", null);

    public String getBaseUrl() {
        return getString(baseUrl);
    }

    public void setBaseUrl(String v) {
        setString(baseUrl, v, null);
    }

    public static final Property subSystemType = newProperty(0, BSubSystemType.DEFAULT, null);

    public BSubSystemType getSubSystemType() {
        return (BSubSystemType) get(subSystemType);
    }

    public void setSubSystemType(BSubSystemType v) {
        set(subSystemType, v, null);
    }

    public static final Property pagePath = newProperty(0, "/Subsystem", null);

    public String getPagePath() {
        return getString(pagePath);
    }

    public void setPagePath(String v) {
        setString(pagePath, v, null);
    }

    public static final Property url = newProperty(0, "https://", null);

    public String getUrl() {
        return getString(url);
    }

    public void setUrl(String v) {
        setString(url, v, null);
    }

    public static final Property modulesRoot = newProperty(0, new BFolder(), null);

    public BFolder getModulesRoot() {
        return (BFolder) get(modulesRoot);
    }

    public void setModulesRoot(BFolder v) {
        set(modulesRoot, v, null);
    }

    public static final Property subSystemTypeExpose = newProperty(Flags.HIDDEN, BSubSystemType.expose(), null);

    public String getSubSystemTypeExpose() {
        return getString(subSystemTypeExpose);
    }

    public void setSubSystemTypeExpose(String v) {
        setString(subSystemTypeExpose, v, null);
    }

//    @Override
//    public void changed(Property property, Context context) {
//        super.changed(property, context);
//        if(property.getType() == BSubSystemType.TYPE) {
//            String tag = propertyValueToString(property, context);
//           if(tag.equals(BSubSystemType.url.toString(context))) {
//                this.setFlags(this.getSlot("velocityName"), Flags.HIDDEN, Context.commit);
//                this.setFlags(this.getSlot("modulesRoot"), Flags.HIDDEN, Context.commit);
//                this.setFlags(this.getSlot("url"), 0, Context.commit);
//            } else {
//                this.setFlags(this.getSlot("url"), Flags.HIDDEN, Context.commit);
//                this.setFlags(this.getSlot("velocityName"), 0, Context.commit);
//                this.setFlags(this.getSlot("modulesRoot"), 0, Context.commit);
//            }
//        }
//    }

    public BCommonSubSystem() {
        setTitle("通用系统");
        setNIcon("laptop");
    }

    @Override
    public Type getType() {
        return TYPE;
    }

    public static final Type TYPE = Sys.loadType(BCommonSubSystem.class);
}
